import ModelUtils from '../../utils/ModelUtils.jsx'

export const namespace = 'overtimeRecord';
export const baseUrl = 'overtime/record';

const model = ModelUtils(baseUrl, namespace);

export default {
    ...model,
    reducers: {
        ...model.reducers,
        addDate(state, { payload: { date } }) {
            const selectDate = state.edit.selectDate || new Set(), dateStr = date.format('YYYY-MM-DD');
            selectDate.has(dateStr) ? selectDate.delete(dateStr) : selectDate.add(dateStr);
            return { ...state, edit: { ...state.edit, selectDate: new Set(selectDate) } };
        }
    }
};